//
//  CatogryHeaderCollectionReusableView.m
//  project
//
//  Created by lanou on 15/10/26.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "CatogryHeaderCollectionReusableView.h"
#import <UIButton+WebCache.h>

@implementation CatogryHeaderCollectionReusableView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        //查找全部
        _seatchButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _seatchButton.frame = CGRectMake(kWidth - 100, 0, 80, 30);
        [_seatchButton setTitle:@"查看全部>" forState:(UIControlStateNormal)];
        [_seatchButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        _seatchButton.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:_seatchButton];
        
        //滑动视图
        _headerScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 30, kWidth, 100)];
//        _headerScrollView.backgroundColor = [UIColor greenColor];
        _headerScrollView.contentSize = CGSizeMake(kWidth * 3, 100);
        _headerScrollView.showsHorizontalScrollIndicator = NO;
        [self addSubview:_headerScrollView];
        
        //第一个button
        _firstButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _firstButton.frame = CGRectMake(10, 0, (kWidth * 3 - 70) / 6, 90);
        _firstButton.layer.masksToBounds = YES;
        _firstButton.layer.cornerRadius = 5;
        [_headerScrollView addSubview:_firstButton];
        
        //第二个button
        _secondButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _secondButton.frame = CGRectMake(20 + (kWidth * 3 - 70) / 6 , 0, (kWidth * 3 - 70) / 6, 90);
        _secondButton.layer.masksToBounds = YES;
        _secondButton.layer.cornerRadius = 5;
        [_headerScrollView addSubview:_secondButton];
        
        //第三个button
        _thirdButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _thirdButton.frame = CGRectMake(30 + (kWidth * 3 - 70) / 6 * 2, 0, (kWidth * 3 - 70) / 6, 90);
        _thirdButton.layer.masksToBounds = YES;
        _thirdButton.layer.cornerRadius = 5;
        [_headerScrollView addSubview:_thirdButton];
        
        //第四个button
        _forthButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _forthButton.frame = CGRectMake(40 + (kWidth * 3 - 70) / 6 * 3, 0, (kWidth * 3 - 70) / 6, 90);
        _forthButton.layer.masksToBounds = YES;
        _forthButton.layer.cornerRadius = 5;
        [_headerScrollView addSubview:_forthButton];
        
        //第五个button
        _fifthButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _fifthButton.frame = CGRectMake(50 + (kWidth * 3 - 70) / 6 * 4, 0, (kWidth * 3 - 70) / 6, 90);
        _fifthButton.layer.masksToBounds = YES;
        _fifthButton.layer.cornerRadius = 5;
        [_headerScrollView addSubview:_fifthButton];
        
        //第六个button
        _sixthButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _sixthButton.frame = CGRectMake(60 + (kWidth * 3 - 70) / 6 * 5, 0, (kWidth * 3 - 70) / 6, 90);
        _sixthButton.layer.masksToBounds = YES;
        _sixthButton.layer.cornerRadius = 5;
        [_headerScrollView addSubview:_sixthButton];
        
      
    }
    return self;
}

-(void)setArray:(NSArray *)array
{
    CatogryStrategyHeaderModel *model =  array[0];
    [_firstButton sd_setImageWithURL:[NSURL URLWithString:model.banner_image_url] forState:(UIControlStateNormal)];
    model =  array[1];
    [_secondButton sd_setImageWithURL:[NSURL URLWithString:model.banner_image_url] forState:(UIControlStateNormal)];
    model =  array[2];
    [_thirdButton sd_setImageWithURL:[NSURL URLWithString:model.banner_image_url] forState:(UIControlStateNormal)];
    model =  array[3];
    [_forthButton sd_setImageWithURL:[NSURL URLWithString:model.banner_image_url] forState:(UIControlStateNormal)];
    model =  array[4];
    [_forthButton sd_setImageWithURL:[NSURL URLWithString:model.banner_image_url] forState:(UIControlStateNormal)];
    model =  array[5];
    [_sixthButton sd_setImageWithURL:[NSURL URLWithString:model.banner_image_url] forState:(UIControlStateNormal)];
}



@end
